package com.ruoyi.station.service.impl;

import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.station.domain.SDistributionFrame;
import com.ruoyi.station.domain.SLineManagement;
import com.ruoyi.station.mapper.SLineManagementMapper;
import com.ruoyi.station.service.SLineManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 线路管理Service业务层处理
 *
 * @author ruoyi
 * @date 2021-08-09
 */
@Slf4j
@Service
public class SLineManagementServiceImpl extends ServiceImpl<SLineManagementMapper, SLineManagement> implements SLineManagementService {
    @Autowired
    private SLineManagementMapper sLineManagementMapper;

    /**
     * 导入线路管理数据
     * @param sLineManagements
     * @param updateSupport
     * @param username
     * @return
     */
    @Override
    public String importsSLineManagement(List<SLineManagement> sLineManagements, boolean updateSupport, String username) {
        if (StringUtils.isNull(sLineManagements) || sLineManagements.size() == 0)
        {
            throw new CustomException("导入配线架数据不能为空！");
        }
        int i = 0;
        for (SLineManagement sLineManagement : sLineManagements) {
            sLineManagement.setCreateBy(username);
            i += sLineManagementMapper.insert(sLineManagement);
        }
        return "成功导入"+i+"条";
    }
}
